
//License Information
/*
    Copyright 2010 Jozsef Jantek

    This file is part of HunterTC.

    HunterTC is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    HunterTC is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with HunterTC.  If not, see <http://www.gnu.org/licenses/>.
*/

package huntertc;


public class Char_sheet 
{
    //Attributes
    private int a_str=0, a_agi=0, a_sta=0, a_int=0, a_spi=0;
    private int base_focus=100;
    private int a_rap=0, a_brap=0, a_haste=0, a_crit=0, a_bcrit=0, a_hit=0, a_armp=0;

    //Rotation
    public Shot[] s= new Shot[10];
    public Shot[] pr= new Shot[10];

    //Enemy
    private int e_armor=0, e_magic=0;

    //Weapon
    private int w_min_dmg=0, w_max_dmg=0, w_avg_dmg=0;
    private int w_speed=0, w_dps=0, w_ammo=0, w_scope=0;

    //Buffs
    boolean b_imphawk=false;
    boolean b_imphawk_opt=false;

    boolean b_rapid=false, b_impsteady=false;
    
    boolean b_tactician=false, b_locknload=false, b_expose=false, b_sniper=false, b_serpent=false, b_black=false;
    boolean b_tactician_opt=false, b_locknload_opt=false, b_expose_opt=false;

    //Raidbuffs
    boolean b_Mark=false, b_Hawk=false, b_Trueshot=false;
    boolean b_BOK=false, b_BOM=false, b_Wild=false, b_Pack=false, b_Wrath=false, b_Moonkin=false;
    boolean b_Horn=false, b_Trauma=false, b_Sunder=false, b_Faerie=false, b_FI=false, b_HPres=false, b_Int=false;
    boolean b_Elements=false, b_Fortitude=false;

    //Talents
    public TalentTree t= new TalentTree();

    //Glyphs
    public boolean g_serpent=true, g_steady=true, g_trueshot=true;

    //Show
    public String char_info="";

    //-------------------------------------------------------------------------
    //Constructor
    Char_sheet()
    {
        for(int i=0;i<10;i++) s[i]= new Shot();
    };

    //-------------------------------------------------------------------------
    //Setup all the attributes in one step
    public void setAttributes(int str, int agi, int sta, int intl, int spi)
    {
        setStrength(str);
        setAgility(agi);
        setStamina(sta);
        setIntellect(intl);
        setSpirit(spi);
    };

    //Enemy Armor
    public float getPenDR()
    {
        int arm=getPenArmor();
        float s=(float)(arm/((float)arm+400+85*(80+4.5*(80-59))));
        if(s<=0) return 1;
        else return (float)((int)((1-s)*100))/100;
    }
    public float getDR()
    {
        int arm=e_armor;
        float s=(float)(arm/((float)arm+400+85*(80+4.5*(80-59))));
        if(s<=0) return 1;
        else return (float)((int)((1-s)*100))/100;
    }

    public int getPenArmor()
    {
        int arm=(int)(e_armor*getPenRed());
        if(arm<=0) return 0;
        else return arm;
    }
    public void setArmor(int s) {e_armor=s;}

    //Armor Penetration
    public float getPenRed() {
        float s=getArmp();
        if(b_Sunder) s+=20;
        if(b_Faerie) s+=5;
        if(s>=100) return 0;
        else return 1-(s/100);
    }
    public float getArmp() {
        float s=a_armp;
        if(s>10000) return 100;
        else return s/100;
    }
    public void setArmp(float s) {a_armp=(int)(s*100);}

    //Enemy Magic Resistance
    public void setMR(int s) {e_magic=s;}
    public float getMR() {return 1-((float)e_magic/100);}

    //Strength
    public int getStrength() {
        float s=a_str;
        if(b_Wild) s+=52;
        if(b_Horn) s+=155;
        if(b_BOK) s*=1.1;
        return (int)s;
    }
    public void setStrength(int s) {a_str=s;}

    //Agility
    public int getAgility() {
        float s=a_agi;
        if(b_Wild) s+=52;
        if(b_Horn) s+=155;
        if(b_BOK) s*=1.1;
        return (int)s;
    }
    public void setAgility(int s) {a_agi=s;}

    //Stamina
    public int getStamina() {
        float s=a_sta;
        if(b_Wild) s+=52;
        if(b_Fortitude) s+=214;
        if(b_BOK) s*=1.1;
        return (int)s;
    }
    public void setStamina(int s) {a_sta=s;}

    //Intellect
    public int getIntellect() {
        float s=a_int;
        if(b_Wild) s+=52;
        if(b_Int) s+=60;
        if(b_BOK) s*=1.1;
        return (int)s;
    }
    public void setIntellect(int s) {a_int=s;}

    //Spirit
    public int getSpirit() {
        float s=a_spi;
        if(b_Wild) s+=52;
        if(b_BOK) s*=1.1;
        return (int)s;
    }
    public void setSpirit(int s) {a_spi=s;}

    //Ranged Attack Power
    public int getRAP() {
        RefreshRAP();
        int rap=a_rap;
        if(b_Mark) rap+=500+50*t.MM[5].val;
        if(b_Hawk) rap+=300;
        if(b_BOM) rap+=550;
        if(b_expose) rap+=(int)(0.25*getAgility());
        if(b_expose_opt) rap+=(int)(0.25*getAgility()*(t.SV[19].val==1?0.75:1));
        if(b_Trueshot) rap*=1.1;
        return rap;
    }
    public int getBonusRAP(){return a_brap;}
    public void setBonusRAP(int s) {a_brap=s;}
    public void RefreshRAP() {a_rap=getAgility()+(getIntellect()*t.MM[4].val/3)+(getStamina()*t.SV[14].val/10)+getBonusRAP();}

    //Haste
    public float getHaste()
    {
        float temp=a_haste;
        if(b_imphawk) temp+=(t.BM[1].val*300);
        if(b_imphawk_opt) temp+=(t.BM[1].val*180);
        if(b_Moonkin) temp+=300;
        return (float)temp/100;
    }
    public void setHaste(float s) {a_haste=(int)(s*100);}

    //Crit chance
    public float getCrit() {
        a_crit=(int)((t.MM[3].val+t.MM[21].val+t.SV[15].val+getBonusCrit()+getAgility()/83.33)*100);
        int s=a_crit;
        if(b_Pack) s+=500;
        if(b_Wrath) s+=300;
        if(b_tactician) s+=(200*t.SV[22].val);
        if(b_tactician_opt) s+=(140*t.SV[22].val);
        return (float)s/100;
    }
    public float getBonusCrit() {return (float)a_bcrit/100;};
    public void setBonusCrit(float s) {a_bcrit=(int)(s*100);}

    //Hit chance
    public float getHit() {
        float s=a_hit;
        if(b_HPres) s+=100;
        return s/100;
    }
    public void setHit(float s) {a_hit=(int)(s*100+t.MM[2].val*100);}

    public float getMiss() {
        if(8-getHit()>0) return 8-getHit();
        else return 0;
    }

    //Bonus Damage
    //Haste
    public float getBonDmg()
    {
        float s=100+t.SV[1].val+t.BM[3].val+t.MM[27].val;
        if(t.MM[17].val==3) s+=5;
        else if(t.MM[17].val==2) s+=3;
        else if(t.MM[17].val==1) s+=1;
        if(b_FI) s+=3;
        if(b_black) s+=6;
        if(b_serpent) s+=t.SV[23].val;
        if(b_sniper) s+=t.SV[26].val*2;
        return s/100;
    }

    //Base mana
    public int getBase_focus() {return base_focus;}
    public void setBase_focus(int s) {base_focus=s;}
    
    //-------------------------------------------------------------------------
    //-------------------------------------------------------------------------
    //Set all weapon attributes in one step
    public void setWeapon(int smin_dmg, int smax_dmg, float sspeed, float sammo, int sscope)
    {
        setWep_min_dmg(smin_dmg);
        setWep_max_dmg(smax_dmg);
        setWep_avg_dmg();
        setWep_speed(sspeed);
        setWep_dps(getWep_avg_dmg(),getWep_speed());
        setWep_ammo(sammo);
        setWep_scope(sscope);
    }

    //Weapon Average Damage
    public int getWep_avg_dmg() {return w_avg_dmg;}
    public void setWep_avg_dmg() {w_avg_dmg=(getWep_min_dmg()+getWep_max_dmg())/2;}

    //Weapon Minimum Damage
    public int getWep_min_dmg() {return w_min_dmg;}
    public void setWep_min_dmg(int s) {w_min_dmg=s;}

    //Weapon Maximum Damage
    public int getWep_max_dmg() {return w_max_dmg;}
    public void setWep_max_dmg(int s) {w_max_dmg=s;}

    //Weapon Speed
    public float getWep_speed() {return (float)w_speed/100;}
    public void setWep_speed(float s) {w_speed=(int)(s*100);}

    //Weapon DPS
    public float getWep_dps(){return (float)w_dps/100;}
    public void setWep_dps(int dam, float tim) {w_dps=(int)(dam/tim*100);}

    //Weapon Ammo
    public float getWep_ammo() {return (float)w_ammo/100;}
    public void setWep_ammo(float s) {w_ammo=(int)(s*100);}

    //Weapon Scope
    public int getWep_scope() {return w_scope;}
    public void setWep_scope(int s) {w_scope=s;}

    //-------------------------------------------------------------------------
    //-------------------------------------------------------------------------
    //Show current values of all the attributes
    public void ShowAll()
    {
        char_info="";
        char_info+=("\n*****Basic Attributes*****");
        char_info+=("\nStrength: "+getStrength()+"\nAgility: "+getAgility()+"\nStamina: "+getStamina()+"\nIntellect: "+getIntellect()+"\nSpirit: "+getSpirit()+"\n");
        char_info+=("\n*****Weapon Attributes*****");
        char_info+=("\nWeapon Average Damage: "+getWep_avg_dmg()+"\nWeapon Speed: "+getWep_speed()+"\nWeapon DPS: "+getWep_dps()+"\nWeapon Ammo DPS: "+getWep_ammo()+"\nWeapon Scope: "+getWep_scope()+"\n");
        char_info+=("\n*****Ranged attack*****");
        char_info+=("\nRAP: "+getRAP()+"\nHaste: "+getHaste()+"%\nCrit chance: "+getCrit()+"%\nHit chance: "+getHit()+"%");
    }
}

